package com.movie.mapper;

import com.movie.entity.Rating;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface RatingMapper {

    Rating findByUserAndMovie(@Param("userId") Integer userId,
                              @Param("movieId") Integer movieId);

    int insertRating(Rating rating);

    int updateRating(Rating rating);

    List<Rating> findByMovieId(Integer movieId);

    List<Rating> findByUserId(Integer userId);

    // ⭐ 新增：根据电影ID查询平均分
    Double selectAvgScoreByMovie(@Param("movieId") Integer movieId);
}
